#pragma once


#include <mathlib/intype.h>


BEGIN_NAMESPACE_OXGE

template<typename T> 
class GRAPHIC_TRANSFER Point3T
{
public:

	typedef T ValueType;
	typedef Point3T<T> PointType;
	typedef Vector3T<T> VectorType;
	typedef Vector4T<T> AffineVectorType;

	Point3T(){}

	Point3T(T x, T y, T z ){ Set(x,y,z); }

	PointType& Set(T fx, T fy, T fz){	x = fx; y = fy; z = fz;	return *this;	}

	PointType& Set(const T* cv ){	memcpy(c_v, cv, sizeof(T)*NLen); return *this;	}

	PointType operator+(const VectorType& vec)const{ return PointType(x+vec.x, y+vec.y, z+vec.z); }
	PointType operator-(const VectorType& vec)const{ return PointType(x-vec.x, y-vec.y, z-vec.z); }

	inline PointType& operator+=(const VectorType& vec){ x += vec.x ;  y+= vec.y; z+= vec.z; return *this; }

	VectorType operator - (const PointType& pt)const{ return VectorType(x - pt.x, y - pt.y, z-pt.z); }

	inline AffineVectorType GetAffineVector()const{	return AffineVectorType(x, y, z, 1); }

	const static PointType ZERO;

	inline operator ValueType*() { return c_v; }	
	inline operator const ValueType*()const { return c_v; }

protected:

	const static size_t NLen = 3;
	union{
		struct{
			T x,y,z;
		};
		T c_v[NLen];
	};

};

template <typename T> 
const Point3T<T> Point3T<T>::ZERO(0,0,0);



END_NAMESPACE_OXGE